package com.wolves.career.controller;

import com.wolves.career.service.OssService;
import com.wolves.career.utils.R;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 麦翔盛
 * @description: oss服务器控制类
 * @date 2021/10/20 19:33
 */
@RestController
@CrossOrigin
@RequestMapping("/oss/fileoss")

public class OssController {
    @Autowired
    private OssService ossService;

    /**
     * 上传头像
     * @param file 文件
     * @return 返回头像地址
     */
    @PostMapping("/upload")
    public R uploadOssFile(MultipartFile file){
        String url = ossService.uploadFileAvatar(file);
        return R.ok().data("url",url);
    }
}
